Returned Values and Out Parameters

For languages which have output parameters, e.g. Pascal, multiple values are returned. The first value is the return-value of the foreign procedure, unless it is of return-type ignore, followed by the out parameters. Thus a call to the T procedure aegis-read, defined above, would return two values: retlen and status. For a Pascal procedure the return spec will always be ignore. The argument to a foreign procedure should usually be of type ignore if it is an out parameter to the foreign procedure that is bigger than a longword. Also, the value of any out parameters which are not needed can be specified as ignore.

Pascal functions which return addresses must have return-type of type rep/address. If this value is passed to another foreign call it should be with rep/integer.

define-foreign does not allocate storage for out parameters. This means that you must allocate your own object and pass it to the foreign procedure even if it is only an out parameter. If it is an out parameter which is other than an integer then its foreign-type should be ignore and the variable passed in should be used to reference the parameter.